package chap05;

import java.util.Scanner;

public class GuessGame {
    public static void start() {
        /*
        * 1.产生随机数
        * 2.循环：（猜中为止）
        * 接受输入
        * 判断：提示大于，小于
        * 猜中，提示并退出*/
        //math.random()得到的是大于等于0且小于1的double
        int random=(int)(Math.random()*10);
        int guess=-1;
       while (guess!=random){
           System.out.println("请输入猜测数：（0-9）");
           Scanner scanner=new Scanner(System.in);
           guess=scanner.nextInt();

           if (guess>random){
               System.out.println("大了");
           }else if(guess<random){
               System.out.println("小了");
           }else{
               System.out.println("中了");
               break;
           }
       }

    }
}
